<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class UpGoodsRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'=>'required',
            'spec'=>'required',
            'menu_id'=>'required',
            'specs.*.*'=>'required',
            'price.*.*'=>'required | numeric',
            'pre_price.*.*'=>'numeric',
            'stock.*.*'=>'required | numeric',
            'describe'=>'required'
        ];
    }
    public function messages(){
        return [
            'name.required'=>'商品名称不能为空',
            'spec.required'=>'商品规格不能为空',
            'menu_id.required'=>'商品所属分类不能为空',
            'specs.*.*.required'=>'商品属性不能为空',
            'price.*.*.required'=>'商品现价不能为空',
            'price.*.*.numeric'=>'商品现价只能是数字',
            'pre_price.*.*.numeric'=>'商品原价只能是数字',
            'stock.*.*.required'=>'商品库存不能为空',
            'stock.*.*.numeric'=>'商品库存只能是数字',
            'describe.required'=>'商品描述不能为空'
        ];
    }
}